@extends('layouts.admin')


@section('content')
<div class="row">

    @if(Auth::check())
    <div class="col-md-offset-1 col-md-10">
        <h1 class="text-center" >电影列表</h1>

        <ul>

            @foreach($movies as $movie)
<hr>
                <ul>
                    <h5>
                        {{$movie->id}}
                        {{$movie->name_en.'=[=]='.$movie->name_zh}}
                        <a href="{{route('movie.edit',$movie)}}">编辑</a>
                        <a href="{{route('movie.swap',$movie)}}">置换</a>
                        @if($movie->episodes()->count()==0)
                            {!! Form::open(['route' => ['movie.destroy',$movie], 'method' => 'delete']) !!}
                            {!! Form::submit('del', ['class' => 'form-control btn-xs btn-danger']) !!}
                            {!! Form::close() !!}
                        @endif
                    </h5>

                    @foreach($movie->episodes as $episode)
                        <li>
                            {{$episode->raw_name}}
                        </li>

                    @endforeach



                </ul>





            @endforeach







        </ul>






    </div>
    @else


        @foreach($movies as $movie)
        <div class="media">
            <div class="media-left media-middle">
                <a href="{{$movie->site_url}}">
                    <img class="media-object" src="{{$movie->coverage_image}}" alt="{{$movie->full_name}}">
                </a>
            </div>
            <div class="media-body">
                <h2 class="media-heading"><a href="{{$movie->site_url}}">{{$movie->full_name}}</a> </h2>
                <ul>
                    @foreach($movie->episodes as $episode)
                        <li>
                            <a data-toggle="collapse" href="{{'#movie'.$movie->id.'ep'.$episode->id}}" aria-expanded="false" aria-controls="{{'movie'.$movie->id.'ep'.$episode->id}}">
                            {{$episode->raw_name}}
                            </a>
                            <div class="collapse" id="{{'movie'.$movie->id.'ep'.$episode->id}}">
                                <p>{!! $episode->source_icon !!}</p>
                            </div>
                        </li>
                    @endforeach
                </ul>


            </div>
        </div>
        <hr>
        @endforeach


    @endif

</div>

<div class="center-block">
    {!! $movies->render() !!}

</div>
@endsection

